package com.simpay.cashierapptest;

import lib.Core;
import Core.Contants;
import Core.GlobalData;
import DTO.Auth;
import DTO.Client;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class StartActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		Core.context = this;
		Core.context_private = this;

		// Core.writeData(Contants.ISFIRSTSTART, null);
		// Core.writeData(Contants.PINCODE, null);
		System.out.println(".....Cashier.....");

		initialize();

	}

	public static void initialize() {

		// LiveThread.getInstance();

		Boolean isfirststart = (Boolean) Core.readData(Contants.ISFIRSTSTART);
		GlobalData.firstStart = true;
		if (isfirststart != null) {
			GlobalData.firstStart = false;
		}

		GlobalData.client = (Client) Core.readData(Contants.CLIENT);
		GlobalData.auth = (Auth) Core.readData(Contants.AUTH);

		checkFirstStart();
	}

	public static void checkFirstStart() {

		if (GlobalData.firstStart) {
			Intent i = new Intent(Core.context, LoginActivity.class);
			Core.context.startActivity(i);
		} else {
			if (Core.readData(Contants.PINCODE) == null) {
				// Intent i = new Intent(Core.context,
				// CreatePincodeActivity.class);
				// Core.context.startActivity(i);
			} else {
				// Intent i = new Intent(Core.context, PincodeActivity.class);
				// Core.context.startActivity(i);
			}
		}

		// Intent i = new Intent(Core.context, MainActivity.class);
		// Core.context.startActivity(i);
	}

	@Override
	protected void onStop() {
		super.onStop();
		finish();
	}
}
